package hzn.controller;

import hzn.bean.Person;
import hzn.bean.YmlFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.text.SimpleDateFormat;

@RestController
public class PersonCtrl {
    @Autowired
    Person p;
    @Autowired
    Environment env;
    @Autowired
    YmlFactory y;

    @RequestMapping("/getP")
    public Person getP() throws ParseException {
//        System.out.println(env);
//        p.setAge(Integer.parseInt(env.getProperty("person.age")));
//        p.setBirth(new SimpleDateFormat("yyyy/MM/dd").parse(env.getProperty("person.birth")));
        System.out.println(y);
        return p;
    }
}
